import request from '../utils/request';
import qs from 'qs';
import config from '../utils/config';

export async function createAddress(address) {
	return request(`/ecs/address/add.action`, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(address)
	})
}
export async function modifyAddress(address) {
	return request(`/ecs/address/modify.action`, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(address)
	})
}

export async function fetchAddress(userId) {
	return request(`/ecs/address/list.action?userId=${userId}`, {
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
}

export async function deleteAddress(address) {
	return request(`/ecs/address/remove.action`, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(address)
	})
}

export async function fetchProvince() {
	return request(`/region/list.action`, {
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
}

export async function fetchRegion(regionId) {
	return request(`/region/getRegionById.action?regionId=${regionId}`, {
		headers: {
	      'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
}

export async function fetchShipping() {
	return request(`/ecs/shipping/list.action`, {
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
}


